package org.jeecg.vo.meter;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecg.common.util.DateUtils;
import org.jeecg.enums.meter.*;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 仪表基础信息导出-数据对象
 */
@Data
public class ExportMeterVo {

    /**表编号*/
    @Excel(name = "表号/地址", width = 15)
    @ApiModelProperty(value = "表号/地址")
    private String meterCode;
    @ApiModelProperty(value = "采集器地址")
    @Excel(name = "采集器地址", width = 15)
    private  String collectorAddress;
    /**表类型(1：电表   2：水表)*/
    private Integer meterType;

    @Excel(name = "表类型", width = 15)
    private String meterTypeName;
    /**表名称*/
    @Excel(name = "设备名称", width = 15)
    @ApiModelProperty(value = "设备名称")
    private String name;
    /**初始金额*/
    @Excel(name = "初始金额", width = 15)
    @ApiModelProperty(value = "初始金额")
    private String beginAmount;
    @Excel(name = "初始读数", width = 15)
    private String beginUse;
    private Integer switchStatus;

    //最后读表时间table展示

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date lastReadTime;
    @Excel(name = "读表时间", width = 15)
    private String lastReadTimeStr;

    //最新读数table展示`
    @Excel(name = "读数", width = 15)
    private String newRead;
    @Excel(name = "充值金额", width = 15)
    private String amount;
    @Excel(name = "剩余量", width = 15)
    private String remainUse;
    @Excel(name = "剩余金额", width = 15)
    private String remainAmount;

    @Excel(name = "项目名称", width = 15)
    @ApiModelProperty(value = "项目名称")
    private String projectName;
    @Excel(name = "地址", width = 15)
    @TableField(exist = false)
    private String address;
    /**设备网关*/
    @Excel(name = "设备网关", width = 15)
    @ApiModelProperty(value = "设备网关")
    private String meterGatewayName;
    @Excel(name = "通断状态", width = 15)
    @ApiModelProperty(value = "通断状态（1:通 2:断）")
    private String switchStatusName;
    /**欠费通断用量*/
    @Excel(name = "欠费通断量", width = 15)
    @ApiModelProperty(value = "欠费通断量")
    private Integer switchUse;
    /**线损*/
    @Excel(name = "线损", width = 15)
    @ApiModelProperty(value = "线损")
    private String loss;
    /**倍率*/
    @Excel(name = "倍率", width = 15)
    @ApiModelProperty(value = "倍率")
    private Integer rate;

    /**以下前台反选集合*/
    @Excel(name = "收费项", width = 15)
    @ApiModelProperty(value = "收费项")
    @TableField(exist = false)
    private String meterFee;

    @ApiModelProperty(value = "在线状态(1:在线  0:不在线)")
    private Integer onlineStatus;
    @Excel(name = "在线状态", width = 15)
    private String exOnlineStatus;

    @ApiModelProperty(value = "使用状态(0：正常  1：停用  2：封存 3：已换表)")
    private Integer useStatus;
    @Excel(name = "使用状态", width = 15)
    private String useStatusName;

    private Integer warningStatus;
    /**预警状态（0：否   1：是）*/
    @Excel(name = "预警状态", width = 15)
    @ApiModelProperty(value = "预警状态（0：否   1：是）")
    private String warningStatusName;

    /**预警用量*/
    @Excel(name = "预警用量", width = 15)
    @ApiModelProperty(value = "预警用量")
    private Integer warningUse;

    /**备注*/
    @Excel(name = "备注", width = 15)
    @ApiModelProperty(value = "备注")
    private String remarks;
    public String getExOnlineStatus(){
        return MeterOnlineEnum.getDesc(this.getOnlineStatus());
    }
    public String getWarningStatusName(){
        return MeterWarningStatusEnum.getDesc(this.getWarningStatus());
    }
    public String getSwitchStatusName() {
        return MeterSwitchStatusEnum.getDesc(this.getSwitchStatus());
    }
    public String getMeterTypeName() {
        return MeterTypeEnum.getDesc(this.getMeterType());
    }

    public String getUseStatusName() {
        return MeterUseStatusEnum.getDesc(this.getUseStatus());
    }

    public String getLastReadTimeStr() {
        if (this.getLastReadTime() == null) return "";
        return DateUtils.date2Str(this.getLastReadTime(),DateUtils.datetimeFormat);
    }
}
